package com.openxt.nbzj.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.alibaba.fastjson.JSONObject;
import com.openxt.nbzj.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by tongky on 2016/5/19.
 */
public class EnterpriseGetNativeListAdapter extends BaseAdapter {
    /** 授权列表 */
    private List<JSONObject> mList = null;

    /** 上下文对象 **/
    private Context mContext = null;

    public EnterpriseGetNativeListAdapter(Context context, List<JSONObject> list) {
        mContext = context;
        mList = list;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView != null) {
            viewHolder = (ViewHolder) convertView.getTag();
        } else {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.enterprise_getnative_item, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }

        JSONObject item = mList.get(position);
        viewHolder.Name.setText(item.getString("Name"));
        viewHolder.Address.setText(item.getString("Address"));
        viewHolder.Owner.setText(item.getString("Owner"));

        return convertView;
    }

    class ViewHolder {
        @BindView(R.id.title0)
        TextView Name;
        @BindView(R.id.title1)
        TextView Address;
        @BindView(R.id.title2)
        TextView Owner;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}

